
# basic implementation of vertex
# in this case with no value
class Vertex:   
    def __init__(self,id):
        self.Id = id
        self.Children = set()
        self.Visited = False
        
    # simple implementation of DFS search
    # gets an id to search and the depth of searching
    # for iterative deepening search
    def DFSfind(self,ID,depth = None):
        if depth != None:
            if depth < 0:
                return None
            depth = depth - 1
        self.Visited = True
#        print("DFS visiting " + str(self.Id))
        if self.Id == ID:
            return self
        else:
            for child in self.Children:
                if child.Visited:
                    continue
                tmpChild = child.DFSfind(ID,depth)
                if tmpChild != None:
                    return tmpChild
            return None     
         
    # gets a new id guaranteed to be unique in the graph
    # adds a new vertex with that id as a child to the current vertex
    def addChild(self,ID):
        newVertex = Vertex(ID)
        self.Children.add(newVertex)
        return newVertex
    
    # adds an existing vertex as a child to the current vertex
    def addExistingChild(self,child):
        self.Children.add(child)
        